
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>总线译码器 · WQ GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-intopic-toc/style.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-callouts/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-page-footer-ex/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-theme-comscore/test.css">
                
            
        

    

    
        
        <link rel="stylesheet" href="../styles/styles.css">
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="../faq/introduction.html" />
    
    
    <link rel="prev" href="enable_signal.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../lab0/introduction.html">
            
                <a href="../lab0/introduction.html">
            
                    
                    LAB0: 工欲善其事 必先利其器
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../lab0/FPGAintro.html">
            
                <a href="../lab0/FPGAintro.html">
            
                    
                    FPGA 简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../lab0/whyFPGA.html">
            
                <a href="../lab0/whyFPGA.html">
            
                    
                    为什么是 FPGA？
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../lab0/design_method.html">
            
                <a href="../lab0/design_method.html">
            
                    
                    设计方法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4" data-path="../lab0/board_intro.html">
            
                <a href="../lab0/board_intro.html">
            
                    
                    平台介绍
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.5" data-path="../lab0/intro_tools.html">
            
                <a href="../lab0/intro_tools.html">
            
                    
                    软硬件关系
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.6" data-path="../lab0/keil.html">
            
                <a href="../lab0/keil.html">
            
                    
                    Keil
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.7" data-path="../lab0/vivado.html">
            
                <a href="../lab0/vivado.html">
            
                    
                    Vivado
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.8" data-path="../lab0/modelsim.html">
            
                <a href="../lab0/modelsim.html">
            
                    
                    Modelsim
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../lab1/introduction.html">
            
                <a href="../lab1/introduction.html">
            
                    
                    LAB1: "施法"让 CPU 动起来
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../lab1/sec_1.html">
            
                <a href="../lab1/sec_1.html">
            
                    
                    ARM 汇编回顾
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../lab1/sec_2.html">
            
                <a href="../lab1/sec_2.html">
            
                    
                    搭建 Keil 环境
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../lab1/sec_3.html">
            
                <a href="../lab1/sec_3.html">
            
                    
                    运行吧, 第一个汇编程序
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="../lab1/sec_5.html">
            
                <a href="../lab1/sec_5.html">
            
                    
                    栈 - 函数调用的指挥官
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5" data-path="../lab1/sec_6.html">
            
                <a href="../lab1/sec_6.html">
            
                    
                    自己动手, 理解函数调用
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../lab2/introduction.html">
            
                <a href="../lab2/introduction.html">
            
                    
                    LAB2: "点石成金" - 实现你的首个 SoC
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../lab2/sec_1.html">
            
                <a href="../lab2/sec_1.html">
            
                    
                    硬件部分说明
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../lab2/sec_2.html">
            
                <a href="../lab2/sec_2.html">
            
                    
                    搭建 Keil 工程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../lab2/sec_3.html">
            
                <a href="../lab2/sec_3.html">
            
                    
                    Modelsim 仿真
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="../lab2/sec_4.html">
            
                <a href="../lab2/sec_4.html">
            
                    
                    下载比特流到 FPGA
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="../lab2/sec_5.html">
            
                <a href="../lab2/sec_5.html">
            
                    
                    将硬件固化到开发板
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.6" data-path="../lab2/sec_6.html">
            
                <a href="../lab2/sec_6.html">
            
                    
                    使用 Keil 调试
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../lab3/introduction.html">
            
                <a href="../lab3/introduction.html">
            
                    
                    LAB3: "灯, 等灯, 等灯"-流水灯的几种点法
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../lab3/data_storage.html">
            
                <a href="../lab3/data_storage.html">
            
                    
                    数据存储器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../lab3/GPIO.html">
            
                <a href="../lab3/GPIO.html">
            
                    
                    GPIO外设实现流水灯
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="../lab3/WaterLight.html">
            
                <a href="../lab3/WaterLight.html">
            
                    
                    硬件流水灯
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../lab4/introduction.html">
            
                <a href="../lab4/introduction.html">
            
                    
                    LAB4: 如何召唤"沉睡的软件"
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../lab4/keyboards.html">
            
                <a href="../lab4/keyboards.html">
            
                    
                    矩阵键盘原理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../lab4/keyboards_waterlight.html">
            
                <a href="../lab4/keyboards_waterlight.html">
            
                    
                    使用矩阵键盘4个按键控制流水灯模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="../lab4/keyboards_led.html">
            
                <a href="../lab4/keyboards_led.html">
            
                    
                    使用矩阵键盘控制数码管显示
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="introduction.html">
            
                <a href="introduction.html">
            
                    
                    附录
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="grammar.html">
            
                <a href="grammar.html">
            
                    
                    Verilog基本语法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" data-path="enable_signal.html">
            
                <a href="enable_signal.html">
            
                    
                    使能信号
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.7.3" data-path="decoder.html">
            
                <a href="decoder.html">
            
                    
                    总线译码器
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../faq/introduction.html">
            
                <a href="../faq/introduction.html">
            
                    
                    常见问题
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="../add_notice.html">
            
                <a href="../add_notice.html">
            
                    
                    补充通知
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="../about/introduction.html">
            
                <a href="../about/introduction.html">
            
                    
                    About
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >总线译码器</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="&#x603B;&#x7EBF;&#x8BD1;&#x7801;&#x5668;">&#x603B;&#x7EBF;&#x8BD1;&#x7801;&#x5668;</h1>
<h2 id="&#x4EC0;&#x4E48;&#x662F;&#x603B;&#x7EBF;&#x8BD1;&#x7801;&#x5668;-&#x6709;&#x4EC0;&#x4E48;&#x7528;">&#x4EC0;&#x4E48;&#x662F;&#x603B;&#x7EBF;&#x8BD1;&#x7801;&#x5668;? &#x6709;&#x4EC0;&#x4E48;&#x7528;?</h2>
<p>&#x5047;&#x5982;&#x672C;&#x5B9E;&#x9A8C;&#x96BE;&#x5EA6;&#x592A;&#x5927;, &#x4F60;&#x60F3;&#x8981;&#x548C;&#x81EA;&#x5DF1;&#x7684;&#x670B;&#x53CB;&#x54ED;&#x8BC9;, &#x8FD9;&#x65F6;&#x4F60;&#x9700;&#x8981;&#x4E00;&#x90E8;&#x624B;&#x673A;&#x548C;&#x670B;&#x53CB;&#x7684;&#x7535;&#x8BDD;&#x53F7;, &#x7ED3;&#x679C;&#x5F88;&#x9057;&#x61BE;, &#x4F60;&#x7684;&#x670B;&#x53CB;&#x5E76;&#x6CA1;&#x6709;&#x63A5;&#x4F60;&#x7684;&#x7535;&#x8BDD;, &#x4F60;&#x53EA;&#x80FD;&#x7EE7;&#x7EED;&#x6253;&#x7535;&#x8BDD;&#x7ED9;&#x4E0B;&#x4E00;&#x4E2A;&#x670B;&#x53CB;. SoC&#x60F3;&#x8981;&#x8BBF;&#x95EE;&#x591A;&#x4E2A;&#x5916;&#x8BBE;&#x7684;&#x65F6;&#x5019;&#x4E5F;&#x662F;&#x5982;&#x6B64;. &#x5F53;&#x5904;&#x7406;&#x5668;&#x6838;&#x53EA;&#x6709;&#x4E00;&#x4E2A; Master &#x603B;&#x7EBF;&#x63A5;&#x53E3;&#x65F6;(&#x76F8;&#x5F53;&#x4E8E;&#x53EA;&#x6709;&#x4E00;&#x90E8;&#x624B;&#x673A;&#x7684;&#x65F6;&#x5019;),  &#x6211;&#x4EEC;&#x6B64;&#x65F6;&#x5C31;&#x9700;&#x8981;&#x8BD1;&#x7801;&#x5668;(&#x8FD0;&#x8425;&#x5546;)&#x53D1;&#x6325;&#x4F5C;&#x7528;. &#x603B;&#x7EBF;&#x8BD1;&#x7801;&#x5668;&#x7684;&#x4E3B;&#x8981;&#x4F5C;&#x7528;&#x662F;&#x5BF9;&#x5730;&#x5740;&#x603B;&#x7EBF;&#x4E0A;&#x7684;&#x5730;&#x5740;&#x4FE1;&#x53F7;&#x8FDB;&#x884C;&#x8BD1;&#x7801;, &#x4E4B;&#x540E;&#x751F;&#x6210;&#x5BF9;&#x5E94;&#x5916;&#x8BBE;&#x7684;&#x9009;&#x62E9;&#x4FE1;&#x53F7;(&#x8FD9;&#x4E2A;&#x8FC7;&#x7A0B;&#x76F8;&#x5F53;&#x4E8E;&#x62E8;&#x901A;&#x4E86;&#x7535;&#x8BDD;). &#x4F46;&#x662F;&#x9700;&#x8981;&#x6CE8;&#x610F;, &#x6B64;&#x65F6;&#x5E76;&#x4E0D;&#x4EE3;&#x8868;&#x5904;&#x7406;&#x5668;&#x6838;&#x5DF2;&#x7ECF;&#x53EF;&#x4EE5;&#x8BBF;&#x95EE;&#x8FD9;&#x4E2A;&#x5916;&#x8BBE;&#x4E86;, &#x751F;&#x6210;&#x9009;&#x62E9;&#x4FE1;&#x53F7;&#x540E;, &#x9700;&#x8981;&#x5224;&#x65AD;&#x5BF9;&#x5E94;&#x5916;&#x8BBE;&#x7684;&#x4F7F;&#x80FD;&#x4FE1;&#x53F7;&#x662F;&#x5426;&#x62C9;&#x9AD8;(&#x4E5F;&#x5C31;&#x662F;&#x4F60;&#x7684;&#x670B;&#x53CB;&#x6709;&#x6CA1;&#x6709;&#x6302;&#x4F60;&#x7684;&#x7535;&#x8BDD;), &#x5982;&#x679C;&#x6B64;&#x65F6;&#x4F7F;&#x80FD;&#x6709;&#x6548;, &#x5219;&#x5904;&#x7406;&#x5668;&#x6838;&#x5C31;&#x53EF;&#x4EE5;&#x8BBF;&#x95EE;&#x8FD9;&#x4E2A;&#x5916;&#x8BBE;&#x4E86;. </p>
<h2 id="&#x8BD1;&#x7801;&#x5668;&#x7684;&#x5E38;&#x89C1;&#x63CF;&#x8FF0;&#x65B9;&#x6CD5;">&#x8BD1;&#x7801;&#x5668;&#x7684;&#x5E38;&#x89C1;&#x63CF;&#x8FF0;&#x65B9;&#x6CD5;</h2>
<h3 id="&#x4F7F;&#x7528;&#x7EC4;&#x5408;&#x903B;&#x8F91;&#x76F4;&#x63A5;&#x8D4B;&#x503C;">&#x4F7F;&#x7528;&#x7EC4;&#x5408;&#x903B;&#x8F91;&#x76F4;&#x63A5;&#x8D4B;&#x503C;</h3>
<p>&#x4EE5;&#x4E00;&#x4E2A;&#x5E38;&#x89C1;&#x7684; 3-8 &#x8BD1;&#x7801;&#x5668;&#x4E3A;&#x4F8B;, &#x6211;&#x4EEC;&#x5148;&#x5217;&#x51FA;&#x5B83;&#x7684;&#x771F;&#x503C;&#x8868;</p>
<table>
<thead>
<tr>
<th style="text-align:center">&#x8F93;&#x5165;</th>
<th style="text-align:center">&#x8F93;&#x51FA;</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:center">A    B     C</td>
<td style="text-align:center">Y0 &#x5230; Y7</td>
</tr>
<tr>
<td style="text-align:center">0    0     0</td>
<td style="text-align:center">1    0     0    0    0    0    0    0</td>
</tr>
<tr>
<td style="text-align:center">0    0     1</td>
<td style="text-align:center">0    1     0    0    0    0    0    0</td>
</tr>
<tr>
<td style="text-align:center">0    1     0</td>
<td style="text-align:center">0    0     1    0    0    0    0    0</td>
</tr>
<tr>
<td style="text-align:center">0    1     1</td>
<td style="text-align:center">0    0     0    1    0    0    0    0</td>
</tr>
<tr>
<td style="text-align:center">1    0     0</td>
<td style="text-align:center">0    0     0    0    1    0    0    0</td>
</tr>
<tr>
<td style="text-align:center">1    0     1</td>
<td style="text-align:center">0    0     0    0    0    1    0    0</td>
</tr>
<tr>
<td style="text-align:center">1    1     0</td>
<td style="text-align:center">0    0     0    0    0    0    1    0</td>
</tr>
<tr>
<td style="text-align:center">1    1     1</td>
<td style="text-align:center">0    0     0    0    0    0    0    1</td>
</tr>
</tbody>
</table>
<p>&#x6839;&#x636E;&#x771F;&#x503C;&#x8868;, &#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x5F97;&#x51FA;&#x8F93;&#x51FA;&#x7684;&#x903B;&#x8F91;&#x8868;&#x8FBE;&#x5F0F;. &#x5229;&#x7528; assign &#x8BED;&#x53E5;, &#x53EF;&#x4EE5;&#x5199;&#x51FA;&#x5BF9;&#x5E94;&#x7684; Verilog &#x4EE3;&#x7801;.</p>
<pre><code class="lang-verilog"><span class="hljs-keyword">module</span> decoder3t8(
    <span class="hljs-keyword">input</span> a, b,c,
    <span class="hljs-keyword">output</span> yo, yl, y2, y3, y4, y5,y6, y7
) ;
    <span class="hljs-keyword">assign</span> y0 = ~a &amp;~b&amp;~c ;
    <span class="hljs-keyword">assign</span> y1=~a &amp;~b&amp;c;
    <span class="hljs-keyword">assign</span> y2= ~a &amp;b&amp; ~c;
    <span class="hljs-keyword">assign</span> y3= ~a &amp;b &amp;c;
    <span class="hljs-keyword">assign</span> y4=a &amp;~b&amp;~c;
    <span class="hljs-keyword">assign</span> y5=a &amp;~b&amp;c ;
    <span class="hljs-keyword">assign</span> y6 =a &amp;b&amp;~c;
    <span class="hljs-keyword">assign</span> y7 =a &amp;b&amp;c;
    <span class="hljs-keyword">endmodule</span>
</code></pre>
<p>&#x8FD9;&#x79CD;&#x65B9;&#x6CD5;&#x53EA;&#x9002;&#x7528;&#x4E8E;&#x7B80;&#x5355;&#x7684;&#x8BD1;&#x7801;&#x5668;, &#x5982;&#x679C;&#x8BD1;&#x7801;&#x5668;&#x4F4D;&#x6570;&#x8FC7;&#x591A;, &#x4F1A;&#x5F88;&#x7E41;&#x7410;.</p>
<h3 id="&#x4F7F;&#x7528;-if-else-&#x8BED;&#x53E5;">&#x4F7F;&#x7528; if-else &#x8BED;&#x53E5;</h3>
<p>&#x5982;&#x679C;&#x4F60;&#x89C9;&#x5F97;&#x4F7F;&#x7528;&#x903B;&#x8F91;&#x8868;&#x8FBE;&#x5F0F;&#x8F93;&#x51FA;&#x5F88;&#x9EBB;&#x70E6;, &#x4F60;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x4F7F;&#x7528;&#x63CF;&#x8FF0;&#x6027;&#x7684;&#x8BED;&#x8A00;&#x6765;&#x7F16;&#x5199;&#x8BD1;&#x7801;&#x5668;. &#x4F7F;&#x7528; if-else &#x8BED;&#x53E5;&#x63CF;&#x8FF0;&#x8F93;&#x5165;&#x8F93;&#x51FA;&#x4E4B;&#x95F4;&#x7684;&#x5173;&#x7CFB;, &#x4E5F;&#x53EF;&#x4EE5;&#x5B9E;&#x73B0;&#x8BD1;&#x7801;&#x5668;. &#x6211;&#x4EEC;&#x8FD8;&#x662F;&#x4EE5; 3-8 &#x8BD1;&#x7801;&#x5668;&#x4E3A;&#x4F8B;, </p>
<pre><code class="lang-verilog"><span class="hljs-keyword">module</span> decoder38if(
    <span class="hljs-keyword">input</span>[<span class="hljs-number">2</span>:<span class="hljs-number">0</span>] a,
    <span class="hljs-keyword">output</span> <span class="hljs-keyword">reg</span> [<span class="hljs-number">7</span>:<span class="hljs-number">0</span>] y
);
    <span class="hljs-keyword">always</span>@ (*)<span class="hljs-keyword">begin</span>
        y= <span class="hljs-number">8&apos;b0</span>;

        <span class="hljs-keyword">if</span>(a [<span class="hljs-number">2</span>])
        <span class="hljs-keyword">begin</span>
            <span class="hljs-keyword">if</span>(a[<span class="hljs-number">1</span>])
            <span class="hljs-keyword">begin</span>
                <span class="hljs-keyword">if</span>(a [<span class="hljs-number">0</span>]) y[<span class="hljs-number">7</span>] = <span class="hljs-number">1&apos;b1</span>;
                <span class="hljs-keyword">else</span> y[<span class="hljs-number">6</span>] = <span class="hljs-number">1&apos;b1</span>;
            <span class="hljs-keyword">end</span>
            <span class="hljs-keyword">else</span>
            <span class="hljs-keyword">begin</span>
                <span class="hljs-keyword">if</span>(a[<span class="hljs-number">0</span>]) y[<span class="hljs-number">5</span>] = <span class="hljs-number">1&apos;b1</span>;
                <span class="hljs-keyword">else</span> y[<span class="hljs-number">4</span>]= <span class="hljs-number">1&apos;b1</span>;
            <span class="hljs-keyword">end</span>
        <span class="hljs-keyword">end</span>
        <span class="hljs-keyword">else</span>
        <span class="hljs-keyword">begin</span>
            <span class="hljs-keyword">if</span>(a[<span class="hljs-number">1</span>])
            <span class="hljs-keyword">begin</span>
                <span class="hljs-keyword">if</span>( a[<span class="hljs-number">0</span>]) y[<span class="hljs-number">3</span>]= <span class="hljs-number">1&apos;b1</span>;
                <span class="hljs-keyword">else</span> y[<span class="hljs-number">2</span>]= <span class="hljs-number">1&apos;b1</span>;
            <span class="hljs-keyword">end</span>
            <span class="hljs-keyword">else</span>
            <span class="hljs-keyword">begin</span>
                <span class="hljs-keyword">if</span>(a[<span class="hljs-number">0</span>]) y[<span class="hljs-number">1</span>]= <span class="hljs-number">1</span>&apos;bl;
                <span class="hljs-keyword">else</span> y[<span class="hljs-number">0</span>]= <span class="hljs-number">1&apos;b1</span>;
            <span class="hljs-keyword">end</span>
        <span class="hljs-keyword">end</span>
    <span class="hljs-keyword">end</span>
<span class="hljs-keyword">endmodule</span>
</code></pre>
<p>&#x4E0A;&#x9762;&#x8FD9;&#x90E8;&#x5206;&#x4EE3;&#x7801;&#x901A;&#x8FC7;&#x5229;&#x7528; if-else &#x8BED;&#x53E5;&#x63CF;&#x8FF0;&#x6BCF;&#x4E00;&#x79CD;&#x60C5;&#x51B5;&#x7684;&#x6761;&#x4EF6;, &#x540C;&#x6837;&#x5B9E;&#x73B0;&#x4E00;&#x4E2A;&#x4E86; 3-8 &#x8BD1;&#x7801;&#x5668;.  </p>
<h3 id="&#x4F7F;&#x7528;-case-&#x8BED;&#x53E5;">&#x4F7F;&#x7528; case &#x8BED;&#x53E5;</h3>
<p>&#x5982;&#x679C;&#x4F60;&#x89C9;&#x5F97; if-else &#x8BED;&#x53E5;&#x8FD8;&#x662F;&#x4E0D;&#x591F;&#x76F4;&#x89C2;, &#x4F60;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x4F7F;&#x7528; case &#x8BED;&#x53E5;&#x6765;&#x7F16;&#x5199;&#x8BD1;&#x7801;&#x5668;. &#x4ECD;&#x7136;&#x4EE5; 3-8 &#x8BD1;&#x7801;&#x5668;&#x4E3A;&#x4F8B;</p>
<pre><code class="lang-verilog">module dec38case(
    input [2:0] a,
    output reg [7:0] y
) ;
    always(*)
    begin
        case(a)
            3&apos;d7: y = 8&apos;b10000000;
            3&apos;d6: y = 8&apos;b01000000;
            3&apos;d5: y = 8&apos;b00100000;
            3&apos;d4: y = 8&apos;b00010000;
            3&apos;d3: y = 8&apos;b00001000;
            3&apos;d2: y = 8&apos;b00000100;
            3&apos;d1: y = 8&apos;b00000010;
            3&apos;d0: y = 8&apos;b00000001;
            default: y = 8&quot; bxxxxxxxx
        endcase
    end
endmodule
</code></pre>
<p>&#x4F7F;&#x7528; case &#x8BED;&#x53E5;&#x76F8;&#x6BD4;&#x4E8E;&#x4F7F;&#x7528; if-else &#x8BED;&#x53E5;, &#x66F4;&#x52A0;&#x76F4;&#x89C2;&#x6E05;&#x6670;.</p>
<h2 id="&#x672C;&#x5B9E;&#x9A8C;&#x4E2D;&#x603B;&#x7EBF;&#x8BD1;&#x7801;&#x5668;&#x7684;&#x63CF;&#x8FF0;&#x65B9;&#x6CD5;">&#x672C;&#x5B9E;&#x9A8C;&#x4E2D;&#x603B;&#x7EBF;&#x8BD1;&#x7801;&#x5668;&#x7684;&#x63CF;&#x8FF0;&#x65B9;&#x6CD5;</h2>
<p>&#x6211;&#x4EEC;&#x5148;&#x4EE5;&#x4E00;&#x4E2A;&#x4F8B;&#x5B50;&#x6765;&#x770B;&#x672C;&#x6B21;&#x5B9E;&#x9A8C;&#x9700;&#x8981;&#x600E;&#x6837;&#x7684;&#x8BD1;&#x7801;&#x5668;.</p>
<p><div align="center"><img src="../img/lab3/01.png" alt="SoC&#x7ED3;&#x6784;&#x56FE;" style="zoom:120%;"><div align="center"></div></div></p>
<center style="color:#000000;font-size:10pt;">&#x5B9E;&#x9A8C;&#x4E09;SoC&#x7ED3;&#x6784;&#x56FE;</center>

<p>&#x4E0A;&#x56FE;&#x662F;<a href="../lab3/introduction.html">LAB3: &quot;&#x706F;, &#x7B49;&#x706F;, &#x7B49;&#x706F;&quot;-&#x6D41;&#x6C34;&#x706F;&#x7684;&#x51E0;&#x79CD;&#x70B9;&#x6CD5;</a>&#x4E2D;&#x5B9E;&#x73B0;&#x7684;SoC, &#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x770B;&#x5230;,  SoC &#x7684;&#x603B;&#x7EBF;&#x4E0A;&#x5916;&#x6302;&#x4E86;&#x56DB;&#x4E2A;&#x5916;&#x8BBE;, &#x5206;&#x522B;&#x4E3A;&#x6307;&#x4EE4;&#x5B58;&#x50A8;&#x5668;(RAMCODE), &#x6570;&#x636E;&#x5B58;&#x50A8;&#x5668;(RAMDATA), &#x901A;&#x8FC7;&#x8F93;&#x5165;&#x8F93;&#x51FA;&#x53E3;(GPIO)&#x4EE5;&#x53CA;&#x6D41;&#x6C34;&#x706F;(WATERLIGHT). &#x6307;&#x4EE4;&#x5B58;&#x50A8;&#x5668;&#x7684;&#x5730;&#x5740;&#x4E3A; 0x00000000 - 0x000000ff, &#x6570;&#x636E;&#x5B58;&#x50A8;&#x5668;&#x7684;&#x5730;&#x5740;&#x4E3A; 0x20000000 - 0x2000ffff, GPIO &#x7684;&#x5730;&#x5740;&#x4E3A; 0x40000020, 0x40000024 &#x548C; 0x40000028, &#x6D41;&#x6C34;&#x706F;&#x7684;&#x5730;&#x5740;&#x4E3A; 0x40000000 - 0x4000000f. </p>
<p>&#x4ECE;&#x5730;&#x5740;&#x4E0A;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x770B;&#x5230;, &#x5982;&#x679C;&#x6211;&#x4EEC;&#x60F3;&#x8981;&#x5BF9;&#x6307;&#x4EE4;&#x5B58;&#x50A8;&#x5668;&#x8FDB;&#x884C;&#x4E00;&#x6B21;&#x64CD;&#x4F5C;, &#x53EA;&#x8981;&#x4FDD;&#x8BC1;&#x5730;&#x5740;&#x7684;&#x9AD8; 16bit &#x4E3A; 0x0000 &#x5373;&#x53EF;. &#x5982;&#x679C;&#x6211;&#x4EEC;&#x60F3;&#x8981;&#x5BF9;&#x6D41;&#x6C34;&#x706F;&#x8FDB;&#x884C;&#x64CD;&#x4F5C;, &#x5219;&#x9700;&#x8981;&#x786E;&#x4FDD;&#x5730;&#x5740;&#x7EBF;&#x7684;&#x9AD8; 28bit &#x4E3A; 0x4000000. &#x53EF;&#x4EE5;&#x770B;&#x5230;, &#x5BF9;&#x4E0D;&#x540C;&#x5916;&#x8BBE;&#x8FDB;&#x884C;&#x64CD;&#x4F5C;&#x65F6;, &#x7531;&#x4E8E;&#x5916;&#x8BBE;&#x7684;&#x6709;&#x6548;&#x5730;&#x5740;&#x957F;&#x5EA6;&#x4E0D;&#x540C;(&#x5982;&#x6307;&#x4EE4;&#x5B58;&#x50A8;&#x5668;&#x7684;&#x6709;&#x6548;&#x957F;&#x5EA6;&#x4E3A; 0x0000 - 0xffff, &#x800C;&#x6D41;&#x6C34;&#x706F;&#x7684;&#x6709;&#x6548;&#x957F;&#x5EA6;&#x4E3A;0x0 - 0xf), &#x4E4B;&#x524D;&#x63D0;&#x5230;&#x7684;&#x51E0;&#x79CD;&#x8BD1;&#x7801;&#x5668;&#x7684;&#x63CF;&#x8FF0;&#x65B9;&#x5F0F;&#x5747;&#x4E0D;&#x662F;&#x5F88;&#x9002;&#x5408;&#x672C;&#x5B9E;&#x9A8C;&#x7684;&#x8BD1;&#x7801;&#x5668;&#x8BBE;&#x8BA1;. </p>
<p>&#x5728;&#x9644;&#x5F55;&#x7684;&#x7B2C;&#x4E00;&#x90E8;&#x5206;<a href="grammar.html">Verilog HDL&#x57FA;&#x672C;&#x8BED;&#x6CD5;</a>&#x4E2D;, &#x6211;&#x4EEC;&#x8BB2;&#x5230;&#x4E86;&#x6761;&#x4EF6;&#x8FD0;&#x7B97;&#x7B26;. &#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x6761;&#x4EF6;&#x8FD0;&#x7B97;&#x7B26; <strong>? : </strong>&#x8FDB;&#x884C;&#x8BD1;&#x7801;. &#x5728;<strong>?</strong>&#x540E;&#x7684;&#x8868;&#x8FBE;&#x5F0F;&#x4E2D;&#x5199;&#x9700;&#x8981;&#x8BBF;&#x95EE;&#x7684;&#x5916;&#x8BBE;&#x7684;&#x5730;&#x5740;, <font style="color: red">: </font>&#x540E;&#x5219;&#x4E3A;&#x5BF9;&#x5E94;&#x5916;&#x8BBE;&#x7684;&#x4F7F;&#x80FD;&#x7AEF;. &#x8FD9;&#x6837;&#x63CF;&#x8FF0;&#x8BD1;&#x7801;&#x5668;&#x53EA;&#x4F7F;&#x7528;&#x4E86; assign &#x8BED;&#x53E5;, &#x7B80;&#x5355;&#x76F4;&#x89C2;, &#x540C;&#x65F6;&#x907F;&#x514D;&#x4E86;&#x4F7F;&#x7528; always &#x8BED;&#x53E5;&#x63CF;&#x8FF0;&#x7EC4;&#x5408;&#x903B;&#x8F91;&#x65F6;&#x5BB9;&#x6613;&#x51FA;&#x73B0;&#x7684;&#x6BDB;&#x523A;&#x7B49;&#x95EE;&#x9898;. </p>
<pre><code class="lang-verilog"><span class="hljs-keyword">assign</span> P0_HSEL = (HADDR[<span class="hljs-number">31</span>:<span class="hljs-number">16</span>] == <span class="hljs-number">16</span>&apos;h0000) ? Port0_en : <span class="hljs-number">1&apos;b0</span>; 
<span class="hljs-keyword">assign</span> P1_HSEL = (HADDR[<span class="hljs-number">31</span>:<span class="hljs-number">16</span>] == <span class="hljs-number">16</span>&apos;h2000) ? Port1_en : <span class="hljs-number">1&apos;b0</span>; 
<span class="hljs-keyword">assign</span> P3_HSEL = (HADDR[<span class="hljs-number">31</span>:<span class="hljs-number">4</span>] == <span class="hljs-number">28</span>&apos;h4000000) ? Port3_en : <span class="hljs-number">1&apos;b0</span>;
<span class="hljs-keyword">assign</span> P4_HSEL = (HADDR[<span class="hljs-number">31</span>:<span class="hljs-number">4</span>] == <span class="hljs-number">28</span>&apos;h4000002) ? Port4_en : <span class="hljs-number">1&apos;b0</span>;
</code></pre>
<p>&#x4E0A;&#x9762;&#x7684;&#x56DB;&#x884C;&#x4EE3;&#x7801;&#x5C55;&#x793A;&#x4E86;&#x672C;&#x6B21;&#x5B9E;&#x9A8C;&#x4E2D;&#x7684;&#x603B;&#x7EBF;&#x8BD1;&#x7801;&#x5668;&#x7684;&#x8BBE;&#x8BA1;&#x65B9;&#x6CD5;. &#x6211;&#x4EEC;&#x4EE5;&#x7B2C;&#x4E00;&#x884C;&#x4EE3;&#x7801;&#x4E3A;&#x4F8B;, &#x5982;&#x679C;&#x5730;&#x5740;&#x4F4D;&#x7684;&#x524D; 16 &#x4F4D;&#x4E3A;16&apos;h0000, &#x5219;&#x628A; Port0_en (&#x4E5F;&#x5C31;&#x662F;&#x6307;&#x4EE4;&#x5B58;&#x50A8;&#x5668;)&#x7684;&#x4F7F;&#x80FD;&#x4FE1;&#x53F7;&#x8D4B;&#x7ED9;&#x7247;&#x9009;&#x4FE1;&#x53F7;, &#x4EE3;&#x8868;&#x603B;&#x7EBF;&#x73B0;&#x5728;&#x5BF9;&#x6307;&#x4EE4;&#x5B58;&#x50A8;&#x5668;&#x8FDB;&#x884C;&#x64CD;&#x4F5C;. &#x4E4B;&#x540E;&#x7684;&#x4EE3;&#x7801;&#x4E5F;&#x662F;&#x540C;&#x7406;.</p>
<footer class="page-footer-ex"> <span class="page-footer-ex-copyright"> By UESTC Intelligent Chip and System Design Lab. &#x91C7;&#x7528;<a href="https://creativecommons.org/licenses/by-nc-sa/3.0/cn/" target="_blank">&#x77E5;&#x8BC6;&#x5171;&#x4EAB; &#x7F72;&#x540D;-&#x975E;&#x5546;&#x4E1A;&#x6027;&#x4F7F;&#x7528;-&#x76F8;&#x540C;&#x65B9;&#x5F0F;&#x5171;&#x4EAB; 3.0 &#x4E2D;&#x56FD;&#x5927;&#x9646; &#x8BB8;&#x53EF;&#x534F;&#x8BAE;</a>&#x53D1;&#x5E03; </span> &#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0; <span class="page-footer-ex-footer-update"> &#x6B64;&#x9875;&#x9762;&#x4FEE;&#x8BA2;&#x4E8E; 2022-02-24 19:15:35 </span> </footer>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="enable_signal.html" class="navigation navigation-prev " aria-label="Previous page: 使能信号">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="../faq/introduction.html" class="navigation navigation-next " aria-label="Next page: 常见问题">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"总线译码器","level":"1.7.3","depth":2,"next":{"title":"常见问题","level":"1.8","depth":1,"path":"faq/introduction.md","ref":"faq/introduction.md","articles":[]},"previous":{"title":"使能信号","level":"1.7.2","depth":2,"path":"verilog/enable_signal.md","ref":"verilog/enable_signal.md","articles":[]},"dir":"ltr"},"config":{"plugins":["intopic-toc","callouts","page-footer-ex","-livereload","theme-comscore","-sharing"],"styles":{"website":"styles/styles.css"},"pluginsConfig":{"callouts":{"important":{"alert":"danger","picto":"fa-bullhorn"},"danger":{"alert":"danger","picto":"fa-exclamation-circle"},"question":{"alert":"info","picto":"fa-question-circle"},"hint":{"alert":"success","picto":"fa-lightbulb-o"},"showTypeInHeader":false,"must":{"alert":"warning","picto":"fa-edit"},"flag":{"alert":"success","picto":"fa-flag"},"info":{"alert":"info","picto":"fa-info-circle"},"note":{"alert":"info","picto":"fa-edit"},"fread":{"alert":"info","picto":"fa-comment"}},"intopic-toc":{"isCollapsed":true,"isScrollspyActive":true,"label":"导航","maxDepth":6,"mode":"nested","selector":".markdown-section h1, .markdown-section h2, .markdown-section h3, .markdown-section h4","visible":true},"page-footer-ex":{"copyright":"By UESTC Intelligent Chip and System Design Lab. 采用[知识共享 署名-非商业性使用-相同方式共享 3.0 中国大陆 许可协议](https://creativecommons.org/licenses/by-nc-sa/3.0/cn/)发布","markdown":true,"update_format":"YYYY-MM-DD HH:mm:ss","update_label":"此页面修订于"},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"highlight":{},"theme-comscore":{},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"WQ GitBook","gitbook":"*"},"file":{"path":"verilog/decoder.md","mtime":"2022-02-24T11:15:35.086Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2023-03-16T07:13:54.762Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-intopic-toc/anchor.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-intopic-toc/gumshoe.polyfills.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-intopic-toc/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-theme-comscore/test.js"></script>
        
    

    </body>
</html>

